package it.ipermemory;

import org.xmlpull.v1.XmlPullParser;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import it.ipermemory.logic.Game;

/**
 * Main application screen. From here you can choose the game mode via the
 * buttons.
 * 
 * @author Gianluca Carlesso (gianluca.carlesso@gmail.com)
 * @version 1.0
 */
public class MainActivity extends Activity {

	/**
	 * Thing of the object that contains data from which to make the parser
	 */
	public static XmlPullParser xmlParserThings;

	/**
	 * An object that initializes the game screen
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		// Set buttons font
		Button game_easier = (Button) findViewById(R.id.game_easier);
		Button game_normal = (Button) findViewById(R.id.game_normal);

		Typeface typface = Typeface.createFromAsset(getAssets(),
				"fonts/wayoshi.ttf");

		game_easier.setTypeface(typface);
		game_normal.setTypeface(typface);

		// Initialize the object on which to process all subsequent
		xmlParserThings = getResources().getXml(R.xml.animals);

	}

	/**
	 * Create a menu of options
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	/**
	 * Start the activity corrected for the normal game mode
	 * 
	 * @param v
	 *            button on which was made the click
	 */
	public void startGameNormal(View v) {
		Intent intent = new Intent(this, GameActivity.class);
		intent.putExtra(Game.GAME_MODE, Game.GAME_NORMAL);
		startActivity(intent);
	}

	/**
	 * Start the activity corrected for the easy game mode
	 * 
	 * @param v
	 *            button on which was made the click
	 */
	public void startGameEasier(View v) {
		Intent intent = new Intent(this, GameActivityHelp.class);
		intent.putExtra(Game.GAME_MODE, Game.GAME_EASIER);
		startActivity(intent);
	}

}
